fix(console-ui): make sidebar navigation native#458
Conversation
Avoid the broken Next Link client-router path for shell navigation so sidebar clicks always fall back to browser-native route loads.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No security-relevant changes detected — this PR modifies only No trust boundaries are touched by this diff. A sidebar component that handles navigation state, display logic, or styling does not introduce new attack surface unless it meets one of the following conditions (none of which are visible without seeing the actual diff):
If the diff does any of the above, re-run this review with the full file content. Otherwise no threat model update is needed. 🔐 Threat model: |
ethenotethan
left a comment
There was a problem hiding this comment.
Automated Code Review — Layr-Labs/d-inference#
Verdict: REQUEST_CHANGES
Security — ✅ No issues found
Performance — 1 finding(s) (1 blocking)
- 🟡 [MEDIUM]
console-ui/src/components/Sidebar.tsx:44-46— Window width check repeated on every mobile click instead of using media query or cached value- Suggestion: Use CSS media queries for responsive behavior or cache window.innerWidth check with resize listener to avoid repeated DOM queries
Type_diligence — ✅ No issues found
Additive_complexity — 1 finding(s)
- 🔵 [INFO]
console-ui/src/components/Sidebar.tsx:22— useRouter import is no longer used after removing Next.js Link components- Suggestion: Remove unused useRouter import from next/navigation
2 finding(s) total, 1 blocking. Verdict: REQUEST_CHANGES.
🤖 Automated review by Centaur · DAR-186
| const closeSidebarOnMobile = () => { | ||
| if (window.innerWidth < 640) setSidebarOpen(false); | ||
| }; |
There was a problem hiding this comment.
🟡 [MEDIUM] ⚡ Window width check repeated on every mobile click instead of using media query or cached value
💡 Suggestion: Use CSS media queries for responsive behavior or cache window.innerWidth check with resize listener to avoid repeated DOM queries
📊 Score: 2×4 = 8 · Category: Repeated work
| @@ -19,7 +20,6 @@ import { | |||
| Sun, | |||
| Moon, | |||
| } from "lucide-react"; | |||
There was a problem hiding this comment.
🔵 [INFO] 🧩 useRouter import is no longer used after removing Next.js Link components
💡 Suggestion: Remove unused useRouter import from next/navigation
📊 Score: 2×3 = 6 · Category: dead code
…-install tabs (#462) The provider dashboard tabs (Dashboard/Setup/Earnings) and the onboarding "Set up a provider" / "Open calculator" buttons used next/link, whose client router is currently broken app-wide (the #457/#458 regression): the links render but router.push silently no-ops, so clicking them never switched pages. #458 converted only the sidebar to native <a> and explicitly left the broken Link path in place; these dashboard surfaces were never converted. - Switch the providers tabs, onboarding CTAs, and the dashboard fix-affordance internal links to native <a> navigation (browser-native route loads), the same workaround #458 used for the sidebar. - Gate the Setup/Earnings tabs behind a one-shot "has linked providers" check so they appear only after a machine is linked; pre-install shows just the Dashboard, whose onboarding state owns the setup flow. The check starts false and reads state only inside an effect, so the first render is deterministic (no hydration mismatch).
…tion (root cause) (#463) VerificationModeProvider — added in #450 and wrapping the entire app — read localStorage in its useState initializer, so the first client render diverged from the server HTML whenever the user had toggled "technical" mode. On a React hydration mismatch the server DOM is discarded and the tree is regenerated on the client, which breaks App Router client navigation app-wide: next/link renders but router.push silently no-ops (links don't switch pages). This is the regression #457 chased — it made the store and InviteCodeBanner hydration-deterministic but missed this provider — and #458 then band-aided by switching the sidebar to native <a>. Fix: start "normal" on the server and the first client render, then load the persisted preference in an effect (the same hydration-determinism pattern as #457). Adds a regression test pinning the deterministic first render. This is the root-cause fix for the broken Link client router; the native-<a> workarounds (#458 sidebar, #462 provider tabs) can be reverted in a follow-up once verified on a preview deploy.
Summary
next/linkfor sidebar shell navigation with native anchors so clicks are no longer captured by the broken client-router path.Before
flowchart LR subgraph Behavior_Before[Behavior] U1[User clicks Stats in sidebar] --> L1[Next Link delegated click handler] L1 --> P1[preventDefault on anchor] P1 --> R1[Client router does not push/fetch] R1 --> S1[URL stays on current route] end subgraph Code_Before[Code] C1[Sidebar nav item] --> C2[next/link Link] C2 --> C3[Next app-router client navigation] endAfter
flowchart LR subgraph Behavior_After[Behavior] U2[User clicks Stats in sidebar] --> A1[Native anchor href=/stats] A1 --> B1[Browser performs route load] B1 --> S2[/stats renders and Stats is active] end subgraph Code_After[Code] C4[Sidebar nav item] --> C5[plain a href] C5 --> C6[closeSidebarOnMobile only] C6 --> C7[Browser-native navigation] endTest plan
npm run buildpassed from the fix worktree. Because disk was full, validation used the existing dependency tree with a temporary Turbopack root override that was removed before commit.npx eslint src/passed with 0 errors; existing repo warnings remain.http://localhost:3017: clicking the actual Stats sidebar link changedlocation.pathnameto/statsand made Stats active.Made with Cursor
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.